#include <iostream>
#include "liste.h"
#include <malloc.h>
#include <ctype.h>
using std::cout;
using std::cin;
Liste::Liste(){
char c;
		insd_P();
		cout<<"Adaugati elemente ? (D/N): ";
		cin>>c;c=toupper(c);
		while(c=='D')
		 {
			 insd_Cs();
			 cout<<"Mai adaugati elemente ? (D/N): ";
			 cin>>c;c=toupper(c);
		}
}
void Liste::listare(void)
	{
		x=p;
		while(x!=NULL)
		 {
			 cout<<"Cheia : "<<x->cheie;
			 x=x->urm;
		 }
	} /* Listare */
void Liste::insd_P(void)
	{
		q=(ref)malloc(sizeof(Tnod));
		cout<<"Cheia : ";cin>>q->cheie;
		q->urm=NULL;
		q->ant=NULL;
		p=q;
	} /* Insd_p */
void Liste::insd_Cs(void)
	{
		s=(ref)malloc(sizeof(Tnod));
		cout<<"Cheia : ";cin>>s->cheie;
		s->urm=NULL;
		q->urm=s;
		q=s;
	} /* Insd_cs */
bool Liste::operator ==(Liste& right)
{
    r=p;
    right.r=right.p;
    int x=1;
    while(r!=NULL && right.r!=NULL)
    {
        if(r->cheie!=right.r->cheie)
            x=0;

        r=r->urm;
        right.r=right.r->urm;
    }
    if(x!=0)
        return true;
    return false;
}
bool Liste::operator !=(Liste& right)
{
    r=p;
    right.r=right.p;
    int x=1;
    while(r!=NULL && right.r!=NULL)
    {
        if(r->cheie!=right.r->cheie)
            x=0;
        r=r->urm;
        right.r=right.r->urm;
    }
    if(x==0)
        return true;
    return false;
}
void Liste::concatenare(Liste& right){
	  right.r=right.p;
		while(right.r!=NULL)
		{
			q->urm=NULL;
			q->urm=right.s;
			q=right.s;
			right.r=right.r->urm;
		}
}
